/*
 *    Copyright 2011-2012 The Hook Team
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.hook.core.mongo;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import com.mongodb.DB;
import com.mongodb.DBCollection;

/**
 * @author suwuqiang 2011-8-22
 */
public interface MongoDAO {

	public String getCollectionName(Class<?> entityClass);

	public DBCollection getCollection(Class<?> entityClass);

	public DBCollection getCollection(String collectionName);

	public DB getDb();

	public void dropCollection(String collectionName);

	public void dropCollection(Class<?> entityClass);

	public Set<String> getCollectionNames();

	public long getCollections();

	public void insert(Object objectToSave);

	public void insert(Collection<? extends Object> batchToSave, Class<?> entityClass);

	public void insert(Object objectToSave, String collectionName);

	public void insert(Collection<? extends Object> batchToSave, String collectionName);

	public void remove(Object obj);

	public void remove(Query query, String collectionName);

	public void remove(Query query, Class<?> entityClass);

	public void update(Query query, Update update, Class<?> entityClass);

	public void update(Query query, Update update, String collectionName);

	public void updateMulti(Query query, Update update, Class<?> entityClass);

	public void updateMulti(Query query, Update update, String collectionName);

	public <T> T load(Object id, Class<T> entityClass);

	public <T> T load(Object id, Class<T> entityClass, String collectionName);

	public <T> List<T> find(Class<T> entityClass);

	public <T> List<T> find(Class<T> entityClass, String collectionName);

	public <T> List<T> find(Query query, Class<T> entityClass);

	public <T> List<T> find(Query query, Class<T> entityClass, String collectionName);

	public <T> T findOne(Query query, Class<T> entityClass);

	public <T> T findOne(Query query, Class<T> entityClass, String collectionName);

	public long count(String collectionName);

	public long count(Query query, String collectionName);

	public long count(Query query, String collectionName, boolean limit);
}
